//
//  AddVoiceView.m
//  CoachsBook
//
//  Created by MaBookPro on 2022/8/26.
//

#import "AddVoiceView.h"

@implementation AddVoiceView


- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
        [self CreateUI];
    }
    return self;
}
-(void)CreateUI{

    UIView *yybackV = [[UIView alloc]initWithFrame:CGRectMake(0, 0, APPwidth, 90)];
    yybackV.backgroundColor = [UIColor whiteColor];
    [self addSubview:yybackV];
    UIView *voiceLine = [[UIView alloc]initWithFrame:CGRectMake(15, 15, 3, 15)];
    voiceLine.backgroundColor = rgba(22, 120, 255, 1);
    voiceLine.layer.cornerRadius = 2;
    [yybackV addSubview:voiceLine];
    UILabel *voiceLab = [[UILabel alloc]initWithFrame:CGRectMake(voiceLine.frame.size.width+voiceLine.frame.origin.x+5,15, 100, 15)];
    voiceLab.text = @"播报标题";
    voiceLab.textColor = [UIColor blackColor];
    voiceLab.textAlignment = 0;
    voiceLab.font = [UIFont systemFontOfSize:16 weight:bold];
    [yybackV addSubview:voiceLab];


    UITextField *txtf = [[UITextField alloc]initWithFrame:CGRectMake(15, voiceLab.frame.size.height + voiceLab.frame.origin.y+15, APPwidth-30, 40)];
    txtf.textColor = rgba(153, 153, 153, 1);
    txtf.placeholder = @"请输入播报标题";
    txtf.font = [UIFont systemFontOfSize:14];
    txtf.textAlignment = 0;
    [yybackV addSubview:txtf];
    

    UIView *titleLine = [[UIView alloc]initWithFrame:CGRectMake(0, yybackV.height-10, APPwidth, 10)];
    titleLine.backgroundColor = rgba(245, 245, 250, 1);
    [yybackV addSubview:titleLine];
    
    //播报正文
    
    UIView *bbbackV = [[UIView alloc]initWithFrame:CGRectMake(0, yybackV.height+yybackV.y, APPwidth, 500)];
    bbbackV.backgroundColor = [UIColor whiteColor];
    [self addSubview:bbbackV];
    UIView *bbLine = [[UIView alloc]initWithFrame:CGRectMake(15, 15, 3, 15)];
    bbLine.backgroundColor = rgba(22, 120, 255, 1);
    bbLine.layer.cornerRadius = 2;
    [bbLine addSubview:voiceLine];
    UILabel *bbLab = [[UILabel alloc]initWithFrame:CGRectMake(bbLine.frame.size.width+bbLine.frame.origin.x+5,15, 100, 15)];
    bbLab.text = @"播报正文";
    bbLab.textColor = [UIColor blackColor];
    bbLab.textAlignment = 0;
    bbLab.font = [UIFont systemFontOfSize:16 weight:bold];
    [bbbackV addSubview:bbLab];
    
    UILabel *typeLab = [[UILabel alloc]initWithFrame:CGRectMake(APPwidth/2-100/2,  15, 100, 20)];
    typeLab.text = @"插入停顿";
    typeLab.textColor = rgba(138, 138, 138, 1);
    typeLab.layer.backgroundColor = rgba(245, 245, 250, 1).CGColor;
    typeLab.textAlignment = 1;
    typeLab.layer.cornerRadius = 10;
    typeLab.font = [UIFont systemFontOfSize:12];
    [bbbackV addSubview:typeLab];

    UIButton *bmBtn = [[UIButton alloc]initWithFrame:CGRectMake(APPwidth-70, 15, 45, 20)];
    [bmBtn setTitle:@"1秒" forState:0];
    bmBtn.contentHorizontalAlignment = 0;
    [bmBtn setBackgroundColor:rgba(226, 239, 255, 1)];
    [bmBtn setTitleColor:rgba(22, 120, 255, 1) forState:0];
    bmBtn.titleLabel.font = [UIFont systemFontOfSize:12];
    bmBtn.layer.cornerRadius = 10;
    [bbbackV addSubview:bmBtn];
    
        
    UITextView *txtv = [[UITextView alloc]initWithFrame:CGRectMake(15, bbLab.height + bbLab.y+15, APPwidth-30, 180)];
    txtv.text = @"请输入播报正文";
    txtv.layer.cornerRadius = 8;
    txtv.backgroundColor = rgba(245, 246, 249, 1);
    [bbbackV addSubview:txtv];
    
    NSArray *stopBtnarr = @[@"30秒",@"",@"1秒"];
    NSArray *titlearr = @[@"停顿30秒",@"点击试听",@"停顿1秒"];
    
    CGFloat btnW = (APPwidth-200)/3;
    CGFloat btnH = 45;
    
    for (int i = 0; i < stopBtnarr.count; i++) {
        
        NSInteger row = i/3;
        NSInteger col = i%3;
        CGFloat btnX = 40 + (btnW + 60 ) * col;
        CGFloat btnY = 40 + (btnH + 60 ) * row;
       
        UIButton *Btn = [[UIButton alloc]initWithFrame: CGRectMake(btnX,btnY+txtv.height+txtv.y+ 80, btnW, btnW)];
        [Btn setTitle:stopBtnarr[i] forState:0];
        Btn.contentHorizontalAlignment = 0;
        [Btn setBackgroundColor:rgba(226, 239, 255, 1)];
        [Btn setTitleColor:rgba(22, 120, 255, 1) forState:0];
        Btn.titleLabel.font = [UIFont systemFontOfSize:14];
        Btn.layer.cornerRadius = 5;
        [self addSubview:Btn];
        
        UILabel *typeLab = [[UILabel alloc]initWithFrame:CGRectMake(0,  Btn.height+5, btnW, 20)];
        typeLab.text = titlearr[i];
        typeLab.textColor = rgba(138, 138, 138, 1);
        typeLab.layer.backgroundColor = rgba(245, 245, 250, 1).CGColor;
        typeLab.textAlignment = 1;
        typeLab.layer.cornerRadius = 10;
        typeLab.font = [UIFont systemFontOfSize:12];
        [Btn addSubview:typeLab];
        
        
    }
    
    UILabel *hint = [[UILabel alloc]initWithFrame:CGRectMake(15,  bbbackV.frame.size.height - 120, APPwidth-30, 20)];
    hint.text = @"提示";
    hint.textColor = rgba(51, 51, 51, 1);
    hint.textAlignment = 0;
    hint.font = [UIFont boldSystemFontOfSize:14];
    [bbbackV addSubview:hint];
    
    UILabel *hintdis = [[UILabel alloc]initWithFrame:CGRectMake(15,  hint.frame.size.height + hint.frame.origin.y, APPwidth-30, 80)];
    hintdis.text = @"1.输入标题和播报正文文字，自动生成语音，点击试听。\n2.如果存在中间需要停顿，点击一次”停顿按钮”。\n3.修改指令文字后，需联网才可试听和保存。";
    hintdis.textColor = rgba(51, 51, 51, 1) ;
    hintdis.textAlignment = 0;
    hintdis.numberOfLines = 0 ;
    hintdis.font = [UIFont systemFontOfSize:12];
    [bbbackV addSubview:hintdis];
    NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:hintdis.text];
    NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
    [paragraphStyle setLineSpacing:5];
    [paragraphStyle setParagraphSpacing:2];
    [attributedString addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, [hintdis.text length])];
    hintdis.attributedText = attributedString;
    
    
    
    
    
    
    
    
    
}






@end
